{% extends 'VipBundle:VipAdmin:layout.html.twig' %}

{% set memberlevel = memberlevel|default(null) %}
{% block title %}
{% if memberlevel %}编辑{% else %}新增{% endif %}会员等级
{% endblock %}

{% set menu = 'memberlevel' %}

{% set script_controller = 'vipbundle/controller/vipleveladmin/save' %}

{% block main %}

<div class="page-header clearfix">
  <h1 class="pull-left">{% if memberlevel %}编辑{% else %}新增{% endif %}会员等级</h1>
</div>
<form id="memberlevel-form" class="form-horizontal" method="post" action="{% if memberlevel %}{{path('admin_vip_level_update',{id:memberlevel.id}) }}{% else %}{{ path('admin_vip_level_create') }}{% endif %}">
  <fieldset>

    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="levelName">会员等级名称</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" id="levelName" name="name" class="form-control" value="{% if memberlevel %}{{ memberlevel.name }}{% endif %}">
      </div>
    </div>

    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="monthType">购买价格</label>
      </div>
      <div class="col-md-6 controls">
        <spann class="form-control-static">包月</spann>
        <input type="text" name="monthPrice" class="form-control width-input width-input-large" value="{% if memberlevel %}{{ memberlevel.monthPrice }}{% else %}0.00{% endif %}">
      </div>
    </div>

    <div class="row form-group">
      <div class=" col-md-offset-2 col-md-6 controls">
        <spann class="form-control-static">包年</spann>
        <input type="text" name="yearPrice" class="form-control width-input width-input-large" value="{% if memberlevel %}{{ memberlevel.yearPrice }}{% else %}0.00{% endif %}">
      </div>
    </div>

    <div class="row form-group" style="display:none;">
      <div class="col-md-2 control-label">
        <label for="freeLearned">可免费学习所有课程</label>
      </div>
      <div class="col-md-7 radios controls">
          {% if memberlevel %} 
            {{ radios('freeLearned', {'1':'是', '0':'否'}, memberlevel.freeLearned) }}
          {% else %}
            {{ radios('freeLearned', {'1':'是', '0':'否'}) }}
          {% endif %}
      </div>
    </div>

    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="memberlevel-content-field">一句话描述</label>
      </div>
      <div class="col-md-7 controls">
        <textarea class="form-control" id="memberlevel-content-field" name="description">{% if memberlevel %}{{ memberlevel.description }}{% endif %}</textarea>
      </div>
    </div>

    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="memberlevel-content-field">设置图片</label>
      </div>
      <div class="col-md-7 controls">
        <input type="hidden" name="picture" value="{% if memberlevel %}{{ memberlevel.picture }}{% endif %}" >
        <p>
          <img id="picture-show" src="{% if memberlevel %}{{ memberlevel.picture }}{% endif %}" class="img-responsive" style="display:block;">
        </p>
        <a href="javascript:;" class="btn btn-default btn-sm" data-url="{{ path('admin_vip_level_picture') }}" data-toggle="modal" data-target="#modal">设置图片</a>
      </div>
    </div>

    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="memberlevel-content-field">设置图标</label>
      </div>
      <div class="col-md-7 controls">
        <input type="hidden" name="icon" value="{% if memberlevel %}{{ memberlevel.icon }}{% endif %}" >
        <p>
          <img id="icon-show" src="{% if memberlevel %}{{ memberlevel.icon }}{% endif %}" class="img-responsive" style="display:block;">
        </p>
        <a href="javascript:;" class="btn btn-default btn-sm" data-url="{{ path('admin_vip_level_icon') }}" data-toggle="modal" data-target="#modal">设置图标</a>
      </div>
    </div>

    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="enabled">加入会员</label>
      </div>
      <div class="col-md-7 controls radios">
        {% if memberlevel %}
           {{ radios('enabled', {'1':'允许', '0':'禁止'}, memberlevel.enabled) }}
        {% else %}
          <label>
            <input type="radio" name="enabled" value="1" checked="checked"> 开启
          </label>
          <label>
            <input type="radio" name="enabled" value="0"> 关闭
          </label>
        {% endif %}
      </div>
    </div>

    <div class="row form-group">
      <div class="col-md-offset-2 col-md-1">
        <input type="submit" class="btn btn-primary pull-left" value="保存">
      </div>   
      <div class="col-md-1">
        <a href="{{ path('admin_vip_level') }}" class="btn btn-link">取消</a>
      </div>
    </div> 

  </fieldset>
    <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
</form>

{% endblock %}